<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
    <title>ShellCheck: SC1133 – Unexpected start of line. If breaking lines, `|`/`||`/`&&` should be at the end of the previous one.</title>
    <link rel="stylesheet" href="css/bootstrap.min.css" />
  </head>
  <body style="margin-left: auto; margin-right: auto; max-width: 800px">
    <h1>SC1133 – ShellCheck Wiki</h1>
    <a href="https://github.com/koalaman/shellcheck/wiki/SC1133">See this page on GitHub</a>
    <p style="display: none"><a href="index.html">Sitemap</a></p>
    <hr />
    <h2
id="unexpected-start-of-line-if-breaking-lines--should-be-at-the-end-of-the-previous-one">Unexpected
start of line. If breaking lines,
<code>|</code>/<code>||</code>/<code>&amp;&amp;</code> should be at the
end of the previous one.</h2>
<h3 id="problematic-code">Problematic code:</h3>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="SC1133.html#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">dmesg</span></span>
<span id="cb1-2"><a href="SC1133.html#cb1-2" aria-hidden="true" tabindex="-1"></a>  <span class="kw">|</span> <span class="fu">grep</span> <span class="st">&quot;error&quot;</span></span></code></pre></div>
<h3 id="correct-code">Correct code:</h3>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="SC1133.html#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="fu">dmesg</span> <span class="kw">|</span></span>
<span id="cb2-2"><a href="SC1133.html#cb2-2" aria-hidden="true" tabindex="-1"></a>  <span class="fu">grep</span> <span class="st">&quot;error&quot;</span></span></code></pre></div>
<h3 id="rationale">Rationale:</h3>
<p>ShellCheck has found a line that unexpectedly started with
<code>|</code>, <code>||</code> or <code>&amp;&amp;</code>. This usually
happens when a line is broken incorrectly.</p>
<p>When breaking around a <code>|</code>, <code>||</code> or
<code>&amp;&amp;</code>, there are two options:</p>
<ul>
<li>Break the line <em>after</em> this token. <code>dmesg</code> is a
complete command by itself, but <code>dmesg |</code> is not so the shell
knows to continue on the next line.</li>
<li>Use a <code>\</code> at the end of the previous line to explicitly
tell the shell to continue on the next.</li>
</ul>
<h3 id="exceptions">Exceptions:</h3>
<p>In v0.7.2 and below, this warning triggered incorrectly when starting
a line with <code>&amp;&gt;</code>. In these versions, you can either <a
href="ignore.html">ignore</a> the warning, or move the redirection after the
command name.</p>
<h3 id="related-resources">Related resources:</h3>
<ul>
<li>Help by adding links to BashFAQ, StackOverflow, man pages, POSIX,
etc!</li>
</ul>
    <hr />
    <p style='font-size: 80%'><a href="../index.html">ShellCheck</a> is a static analysis tool for shell scripts. This page is part of its documentation.</p>
  </body>
</html>


